// Common interfaces for the MCP server
export interface CodeBlock {
  file_path: string;
  identifier: string | null;
  type: string;
  start_line: number;
  end_line: number;
  content: string;
  segmentHash: string;
  fileHash: string;
}

export interface EmbeddingResponse {
  embeddings: number[][];
  usage?: {
    promptTokens: number;
    totalTokens: number;
  };
}

export interface EmbedderInfo {
  name: string;
}

export interface IEmbedder {
  createEmbeddings(texts: string[], docType: 'code' | 'text', task: 'retrieval_query' | 'retrieval_document'): Promise<EmbeddingResponse>;
  validateConfiguration(): Promise<{ valid: boolean; error?: string }>;
  embedderInfo: EmbedderInfo;
}

export interface PointStruct {
  id: string;
  vector: number[];
  payload: Record<string, any>;
}

export interface VectorStoreSearchResult {
  id: string | number;
  score: number;
  payload?: Payload | null;
}

export interface Payload {
  filePath: string;
  codeChunk: string;
  startLine: number;
  endLine: number;
  [key: string]: any;
}

import { DocumentType } from "../utils/instruction-manager";

export interface IVectorStore {
  initialize(): Promise<boolean>;
  upsertPoints(points: PointStruct[], docType: DocumentType): Promise<void>;
  search(queryVector: number[], docType: DocumentType, directoryPrefix?: string, minScore?: number, maxResults?: number): Promise<VectorStoreSearchResult[]>;
  deletePointsByMultipleFilePaths(filePaths: string[], docType: DocumentType): Promise<void>;
  deleteCollection(): Promise<void>;
  collectionExists(docType: DocumentType): Promise<boolean>;
}

export interface ICodeParser {
  parseFile(filePath: string, options?: { content?: string; fileHash?: string }): Promise<CodeBlock[]>;
}

export interface IndexingStats {
  processed: number;
  skipped: number;
  totalBlocks: number;
  errors: number;
}

export interface FileWatcherEvent {
  type: 'created' | 'changed' | 'deleted';
  path: string;
}

export interface IndexStatus {
  state: 'standby' | 'indexing' | 'indexed' | 'error';
  message: string;
  stats?: IndexingStats;
  lastIndexed?: string;
}

export type EmbedderProvider = "openai" | "ollama" | "openai-compatible" | "gemini" | "mistral";
